package com.yehui.alibaba.service.tcc;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * @author 业徽
 * @date 2021/8/4
 */
@LocalTCC
public interface TCCOrderService {

    /**
     * 入库
     *
     * @param userId
     * @param productId
     * @param amount
     * @return
     */
    @TwoPhaseBusinessAction(name = "OrderServiceTCC", commitMethod = "tccCommit", rollbackMethod = "tccRollback")
    Integer add(BusinessActionContext actionContext, Long userId, Long productId, Integer amount);

    /**
     * Commit boolean.
     *
     * @param actionContext the action context
     * @return the boolean
     */
    boolean tccCommit(BusinessActionContext actionContext);

    /**
     * Rollback boolean.
     *
     * @param actionContext the action context
     * @return the boolean
     */
    boolean tccRollback(BusinessActionContext actionContext);

}
